home *** CD-ROM | disk | FTP | other *** search
/ Skunkware 5 / Skunkware 5.iso / tls / tls074c.sunsparc.Z / tls074c.sunsparc / lib / vtcl / tests / msg.tcl < prev    next >
Encoding:
Text File  |  1995-07-20  |  1.6 KB  |  69 lines

  1. # CVS $Id: msg.tcl,v 1.3 1995/02/03 16:55:02 zibi Exp $
  2. #
  3. # Minimal test of messagebox the idea here is to display all the different
  4. # types at once with different options, like new lines, blank titles, etc.
  5. #
  6.  
  7.  
  8. source tools.tcl
  9.  
  10. proc LabelText {parent label text} {
  11.     VtLabel $parent.label -label $label
  12.     set txt [VtText $parent.txt -value $text -verticalScrollBar  1\
  13.          -rightSide FORM  -rows 3]
  14.  
  15.     return $txt
  16. }
  17.  
  18. proc mkDlog {cmd buts txt cbs} {
  19.     set txt [VtGetValues $txt -value]
  20.     set parent [keylget cbs widget]
  21.  
  22.     lappend cmd $parent.$cmd -message $txt 
  23.  
  24.     foreach but $buts {
  25.     if { [VtGetValues $but -value]} {
  26.         set resource [VtGetValues $but -userData]
  27.         lappend cmd $resource
  28.     }
  29.     }
  30.  
  31.     set dialog [eval $cmd]
  32.     VtShow $dialog
  33. }
  34.  
  35. set ap [VtOpen "msg"]
  36.  
  37. set dlog [VtFormDialog $ap.dlog -okLabel Exit -okCallback QuitCB -help]
  38.  
  39. set txt [LabelText $dlog "Message Title" "Default Text"]
  40.  
  41. set rc [VtRowColumn $dlog.rc -leftSide FORM -below $txt -horizontal \
  42.        -CHARM_topOffset 1]
  43.  
  44. foreach but { { OK -ok }  { Cancel -cancel } { Help -help } } {
  45.     set name [lindex $but 0]
  46.     set data [lindex $but 1]
  47.     set b [VtToggleButton $rc.$name -value 1 -userData $data]
  48.     lappend butRay $b
  49. }
  50.  
  51. set dlogs "VtMessageDialog 
  52.        VtErrorDialog 
  53.        VtWarningDialog
  54.        VtInformationDialog
  55.        VtQuestionDialog
  56.        VtWorkingDialog"
  57.  
  58. set rcb [VtRowColumn $dlog.rcb -horizontal -packing COLUMN -numColumns 2\
  59.      -MOTIF_topOffset 10]
  60.  
  61. foreach but $dlogs {
  62.     set b [list $butRay]
  63.     VtPushButton $rcb.$but -callback "mkDlog $but $b $txt"
  64. }
  65.  
  66. VtShowDialog $dlog
  67. VtMainLoop
  68.  
  69.